#!/usr/bin/perl -w #For syntax highlighting
package clreqd_modules;

use strict;
use fstypes;
use clutils qw(DFPORT);

sub resize_fs {
my %ARGS=@_;

	my $lv=$ARGS{LV};
	my $vg=$ARGS{VG};
	my $mnt=$ARGS{MNT};
	my $newsize=$ARGS{NEWSIZE};
	my $oldsize;
	if(exists($ARGS{OLDSIZE})) {
		$oldsize=$ARGS{OLDSIZE};
	}
	if(!defined($oldsize) || $oldsize==0) {
		my $ref=DFPORT($mnt,1024);
		if(!defined($ref)) {
			return "ERROR Unable to determine current file system size of '$mnt'.";
		}
		$oldsize=$ref->{blocks};
	}
		
	my $type=$ARGS{TYPE};

	#########################################################
	# Check to see if the file system is mounted and if so	#
	# use the device from the mount table not the device	#
	# specified since might be different for replicated	#
	# file systems.						#
	#########################################################
	my $mounted=new mnttab;
	my $h=$mounted->get_from_fs($mnt);
	my $blockdev;
	if(defined($h)) {
		$lv=$h->{VG};
		$vg=$h->{LV};
		$blockdev=$h->{BLOCKDEV};
	} else {
		if($vg eq "NA") {
			$blockdev="/dev/$lv";
		} else {
			$blockdev="/dev/$vg/$lv";
		}
	}

	my ($r1,$r2)=do_resize($type,$blockdev,$mnt,$oldsize,$newsize);
	if($r1!=0) {
		return "ERROR $r2";
	}
	return "OK";
}

1;
